package com.github.server.interfaces;

import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;

/**
 * @ClassName HttpResponse
 * @description:
 * @author: biao532
 * @create: 2024-01-31 22:47
 * @Version 1.0
 **/
public interface HttpResponse {
    void setCode(int code);

    void addHeader(String name, String value);

    default void write(byte[] bs) throws IOException {
        write(bs, 0, bs.length);
    }

    default void write(String data) throws IOException {
        write(data.getBytes(StandardCharsets.UTF_8));
    }
    void write(byte[] bs, int offset, int len) throws IOException;
    OutputStream getOutputStream() throws IOException;
}
